/**
 * Copyright &copy; 2015-2020 <a href="http://www.easyhis.com/">easyhis</a> All rights reserved.
 */
package com.easy.dfcshop.entity;

import com.easy.common.utils.IdGen;
import com.easy.common.utils.excel.annotation.ExcelField;
import com.easy.core.persistence.BaseEntity;
import com.easy.modules.sys.entity.User;
import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 用户好友类别:Entity
 * @author waylen chi
 * @version 2018-01-12
 */
public class UserGroup extends BaseEntity<UserGroup> {
	
	private static final long serialVersionUID = 1L;
	private String id;		// 编号
	private Integer groupId;		// 编号
	private User user;		// 用户ID
	private String groupName;		// 类别名称
	private String remarks;		// 备注信息
	private User createBy;		// 创建者
	private Date createTime;		// 创建时间
	private User updateBy;		// 更新者
	private Date updateTime;		// 更新时间
	private String delFlag;		// 删除标记
	
	public UserGroup() {
		super();
	}

	public UserGroup(String id) {
		this.id = id;
	}

	public UserGroup(Integer groupId) {
		this.groupId = groupId;
	}


	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@NotNull(message="编号不能为空")
	@ExcelField(title="编号", align=2, sort=0)
	public Integer getGroupId() {
		return groupId;
	}

	public void setGroupId(Integer groupId) {
		this.groupId = groupId;
	}
	
	@NotNull(message="用户ID不能为空")
	@ExcelField(title="用户ID", fieldType=User.class, value=".userName", align=2, sort=1)
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
	@ExcelField(title="类别名称", align=2, sort=2)
	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
	
	@ExcelField(title="备注信息", align=2, sort=3)
	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	
	@ExcelField(title="创建者", align=2, sort=4)
	public User getCreateBy() {
		return createBy;
	}

	public void setCreateBy(User createBy) {
		this.createBy = createBy;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="创建时间", align=2, sort=5)
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@ExcelField(title="更新者", align=2, sort=6)
	public User getUpdateBy() {
		return updateBy;
	}

	public void setUpdateBy(User updateBy) {
		this.updateBy = updateBy;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="更新时间", align=2, sort=7)
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	@ExcelField(title="删除标记", dictType="del_flag", align=2, sort=8)
	public String getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}

	/**
	 * 插入之前执行方法，需要手动调用
	 */
	public void preInsert(){
		this.id = IdGen.uuid();

		this.updateTime = new Date();
		this.createTime = this.updateTime;
	}

	/**
	 * 更新之前执行方法，需要手动调用
	 */
	public void preUpdate(){
		this.updateTime = new Date();
	}
	/**
	 * 插入之前执行方法，需要手动调用
	 */
	public void preInsert(Date now){
		this.id = IdGen.uuid();

		this.updateTime = now;
		this.createTime = this.updateTime;
	}

	/**
	 * 更新之前执行方法，需要手动调用
	 */
	public void preUpdate(Date now){
		this.updateTime = now;
	}
}